from django.db import models

# Create your models here.
# python manage.py makemigrations
# python manage.py migrate
class Mian(models.Model):
    create_time = models.DateTimeField(auto_now_add=True,verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True,verbose_name="更新时间")

    class Meta:
        # 使模型不会自动创建表
        abstract = True

# 继承Main的字段
class User(Mian):
    id = models.AutoField(primary_key=True)
    # verbose_name 可设置后台显示字段，help_text文本框下方提示字段
    name = models.CharField(max_length=40,unique=True,verbose_name="名称",help_text="请填写姓名")
    age = models.IntegerField(verbose_name="年龄")
    # null=True在admin后台也是必填项，可以设置为Null.blank=True可以在后台不填写
    phone = models.CharField(max_length=11,null=True,blank=True,verbose_name="手机")

    # editable=False,后台不显示次字段(新增字段时，需要设置默认值)
    # tags = models.CharField(max_length=200,default='')
    tags = models.BooleanField(choices=((0,"男"),(1,"女")),verbose_name="性别")
    class Meta:
        db_table = "user"
        verbose_name_plural = "用户信息"
        # verbose_name 为复数形式
